/**********************************************************************************
**
** Copyright (C) 2009 Jostein Bratlie
** Contact: jostein.bratlie@gmail.com | http://bratlie.info | http://episteme.hin.no
**
** This file is part of GMQtExt, a GMlib and Qt extension library
**
** GMQtExt is free software: you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** GMQtExt is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public License
** along with GMQtExt.  If not, see <http://www.gnu.org/licenses/>.
**
**********************************************************************************/

#ifndef SCENEOBJECTPROPERTYBROWSER_H
#define SCENEOBJECTPROPERTYBROWSER_H



// GMlib
namespace GMlib {

  template <typename T, int n>
  class Point;

  class SceneObject;
  class DisplayObject;

  class Color;

  template <typename T> class PCurve;
  template <typename T> class PCircle;

  template <typename T> class PSurf;
  template <typename T> class PSphere;
  template <typename T> class PTorus;
  template <typename T> class PERBSSurf;
}


// local
#include "propertybrowser.h"


namespace GMQtExt {

  class SurfacePlotPropertyManager;


  class SceneObjectPropertyBrowser : public PropertyBrowser {
    Q_OBJECT
  public:
    SceneObjectPropertyBrowser( QWidget* parent = 0x0 );

  public slots:
    virtual void                  createNewObject( GMlib::SceneObject **obj_ptr );
    void                          set( GMlib::SceneObject* obj, bool store_obj );
    void                          update();
    void                          update( GMlib::SceneObject* obj, bool force = false );

  protected:
    void                          beginSetup();
    void                          endSetup();
    const QString&                getCreateType() const;
    void                          setCreateType( const QString& type );

  private:
    SurfacePlotPropertyManager    *_plot_manager;

    GMlib::SceneObject            *_sceneobject;

    QString                       _create_type;

    void                          _setupDisplayObjectProperties( GMlib::DisplayObject* obj );
    void                          _setupSceneObjectProperties( GMlib::SceneObject* obj );
    void                          _setupPCircleFloatProperties( GMlib::PCircle<float>* obj );
    void                          _setupPCurveFloatProperties( GMlib::PCurve<float>* obj );
    void                          _setupPERBSSurfFloatProperties( GMlib::PERBSSurf<float>* obj );
    void                          _setupPSphereFloatProperties( GMlib::PSphere<float>* obj );
    void                          _setupPSurfFloatProperties( GMlib::PSurf<float>* obj );
    void                          _setupPTorusFloatProperties( GMlib::PTorus<float>* obj );

    void                          _updatePSphereFloatProperties( GMlib::PSphere<float>* obj, bool force );
    void                          _updatePTorusFloatProperties( GMlib::PTorus<float>* obj, bool force );
    void                          _updateSceneObjectProperties( GMlib::SceneObject* obj, bool force );

  private slots:
    void                          _slotSurfaceForcedReplot();
    void                          _slotSurfacePlotPropertyChanged( QtProperty*, const GMlib::Point<int,2>&, const GMlib::Point<int,2>& );

  }; // END class SceneObjectPropertyBrowser

} // END namespace GMQtExt




#endif // SCENEOBJECTPROPERTYBROWSER_H
